package com.goldenKey.admin.controller;

import com.goldenKey.common.pojo.result.R;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import com.goldenKey.common.pojo.po.Application;
import com.goldenKey.admin.service.IApplicationService;

/**
 * @Author: 吃我一钊
 * @Description: 申请表控制层
 * @Date: 2025/02/02
 */
@RestController
@RequestMapping("/application")
public class ApplicationController {

	@Autowired
	private IApplicationService applicationService;

	/**
	 * 新增数据
	 * @param application
	 * @return
	 */
	@PostMapping("/save")
	public R<Void> save(@RequestBody Application application) {
		applicationService.save(application);
		return R.ok();
	}

	/**
	 * 根据id删除
	 * @param applicationId
	 * @return
	 */
	@DeleteMapping("/deleteById/{applicationId}")
	public R<Void> deleteById(@PathVariable("applicationId") Integer applicationId) {
		applicationService.removeById(applicationId);
		return R.ok();
	}

	/**
	 * 根据id修改数据
	 * @param application
	 * @return
	 */
	@PutMapping("/updateById")
	public R<Void> updateById(@RequestBody Application application) {
		applicationService.updateById(application);
		return R.ok();
	}

	/**
	 * 根据id查询数据
	 * @param applicationId
	 * @return
	 */
	@GetMapping("/getById/{applicationId}")
	public R<Application> getById(@PathVariable("applicationId") Integer applicationId) {
		Application application = applicationService.getById(applicationId);
		return R.ok(application);
	}
	/**
	 * 查询所有数据
	 * @return
	 */
	@GetMapping("/list")
	public R<List<Application>> list() {
		List<Application> applicationList = applicationService.list();
		return R.ok(applicationList);
	}

}